# class Solution:
#     def uniquePaths(self, m: int, n: int) -> int:
#         total=0
#         def traverse(x,y):
#             nonlocal total
#             if x==n-1 and y==m-1:
#                 total+=1
#             if x+1<n:
#                 traverse(x+1,y)
#             if y+1<m:
#                 traverse(x,y+1)
#         traverse(0,0)
#         return total

class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        result=0
        def sigma(n):
            return sum([i for i in range(1,n+1)])
        if m>n:
            temp=m
            m=n
            n=temp
        if m==3:
            return sigma(n)
        elif m==2:
            return m
        elif m==1:
            return 1   
        if m==n:
            return 2*self.uniquePaths(m-1,n)
        else:
            return self.uniquePaths(m-1,n)+self.uniquePaths(m,n-1)


class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        return comb(m + n - 2, n - 1)

        
s=Solution()
print(s.uniquePaths(23,12))